package duoxiancheng;

/**
 * 礼让线程，暂停线程，直接进入就绪状态
 */
public class YieldDemo {
    public static void main(String[] args) {
        MyYield my = new MyYield();
        new Thread(my,"一").start();
        new Thread(my,"二").start();
    }
}

class MyYield implements Runnable{
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+"-->start");
        Thread.yield();
        System.out.println(Thread.currentThread().getName()+"-->end");
    }
}
